
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-26
 * @see :
 */

public abstract class ModelSeq {

    public final static int    $   = GroupRoot.$MODEL_SEQ$;
    public final static String _   = "MODEL_SEQ$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
   	                                            .lang(Language.$EN_US, "data model sequence", "the sequence of data model(table)")
   	                                            .lang(Language.$ZH_CN, "模块编号", "数据模块编号，以便生成基于数据模块(表)的独立主键")
                                                .done();
    
    public final static int    $CODE  = $ + 1;
    public final static String _CODE  = "MODEL_SEQ$CODE";
    @SystemData
    public final static Code   CODE   = CodeBuilder.code($, $CODE, _CODE)
                                                   .lang(Language.$EN_US, "code table")
                                                   .lang(Language.$ZH_CN, "码表")
                                                   .done();
    public final static int    $ACT  = $ + 2;
    public final static String _ACT  = "MODEL_SEQ$ACT";
    @SystemData
    public final static Code   ACT   = CodeBuilder.code($, $ACT, _ACT)
                                                   .lang(Language.$EN_US, "act table")
                                                   .lang(Language.$ZH_CN, "动作表")
                                                   .done();
    public final static int    $SEQ  = $ + 3;
    public final static String _SEQ  = "MODEL_SEQ$SEQ";
    @SystemData
    public final static Code   SEQ   = CodeBuilder.code($, $SEQ, _SEQ)
                                                   .lang(Language.$EN_US, "seq table")
                                                   .lang(Language.$ZH_CN, "序列表")
                                                   .done();
    public final static int    $USER  = $ + 4;
    public final static String _USER  = "MODEL_SEQ$USER";
    @SystemData
    public final static Code   USER   = CodeBuilder.code($, $USER, _USER)
                                                   .lang(Language.$EN_US, "user table")
                                                   .lang(Language.$ZH_CN, "用户表")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($CODE == id) return true;
        if($ACT == id) return true;
        if($SEQ == id) return true;
        if($USER == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($CODE == id) return CODE;
        if($ACT == id) return ACT;
        if($SEQ == id) return SEQ;
        if($USER == id) return USER;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_CODE.equals(key)) return CODE;
        if(_ACT.equals(key)) return ACT;
        if(_SEQ.equals(key)) return SEQ;
        if(_USER.equals(key)) return USER;
        return null;
    }
}
